#ifndef MEDICINESEARCHWIDGET_H
#define MEDICINESEARCHWIDGET_H

#include <QWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QTableWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QTextEdit>
#include "../../../Common/models.h"
#include "../../../Common/protocol.h"

class MedicineSearchWidget : public QWidget {
    Q_OBJECT
    
public:
    explicit MedicineSearchWidget(QWidget *parent = nullptr);
    ~MedicineSearchWidget();
    
private slots:
    void onSearchClicked();
    void onSearchTextChanged(const QString& text);
    void onMedicineSelected(int row, int column);
    void onMessageReceived(MessageType type, const QJsonObject& data);
    
private:
    void setupUI();
    void loadPopularMedicines();
    void displayMedicines(const QJsonArray& medicines);
    
    QLineEdit* m_searchEdit;
    QPushButton* m_searchButton;
    QTableWidget* m_medicineTable;
    QTextEdit* m_detailText;
    QLabel* m_titleLabel;
};

#endif // MEDICINESEARCHWIDGET_H

